package com.michael.navigationbasicdemo;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;

/**
 * @author: xiaosy
 * 时间: 2022/1/10
 * @Description: java类作用描述
 * @Version: 1.0
 **/
public class FourthFragment extends Fragment {
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        return inflater.inflate(R.layout.fragment_second, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        ((TextView)getView().findViewById(R.id.tvTitle)).setText(this.getClass().getSimpleName());
        int age = (int)getArguments().get("age");
        Log.e("xsy","age:"+age);
        //方法一
        getView().findViewById(R.id.tvTitle).setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                Bundle args = new Bundle();
                args.putInt("age",12);
                Navigation.findNavController(v).navigateUp();

            }
        });
    }
}
